package com.zero.lite.dao.service.impl;

import com.zero.lite.dao.entity.Admin;
import com.zero.lite.dao.entity.Menu;
import com.zero.lite.dao.enums.DictEnum;
import com.zero.lite.dao.mapper.AdminMapper;
import com.zero.lite.dao.mapper.MenuMapper;
import com.zero.lite.dao.service.IAdminService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zero
 * @since 2018-05-04
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements IAdminService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    @Cacheable(value = "MENU",key = "#adminId")
    public List<Menu> queryAllMenus(Integer adminId) {
        List<Menu> menus=menuMapper.queryAllMenus(adminId);
        menus=Menu.buildNodeTree(menus);
        return menus;
    }
}
